<template>
  <div class="icons">
    <swiper :options="swiperOption">
      <swiper-slide v-for="(page, i) in pages" :key="i">
        <div class="icon" v-for="(item, index) in page" :key="index">
          <div class="icon-img">
            <img :src='item.imgUrl' alt="">
            <p class="icon-desc">{{ item.desc }}</p>
          </div>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>
<script>
export default {
  name: 'HomeIcons',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {}
    }
  },
  computed: {
    pages () {
      const pages = []
      this.list.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>
<style lang="stylus" scoped>
  .wrapper >>> .swiper-pagination-bullet-active
    background: rgba(0,175,190,.8)
  .icons
    background-color #fff
    height 0
    overflow hidden
    padding-bottom 50%
    .icon
      padding .2rem 0
      float left
      width 25%
      text-align center
      .icon-img
        img
          width 1.1rem
          height 1.1rem
        .icon-desc
          margin-top .1rem
</style>
